﻿using System.ComponentModel;
using System;

namespace CloudTaobao
{
    public class User
    {
        public string nickName{get;set;}
        public string UID{get;set;}
        public Credit buyerCredit { get; set; }
        public Credit sellerCredit { get; set; }
        public Location Location{get;set;}
        public string Avatar{get;set;}
        public string Email{get;set;}
        public string Created { get; set; }


        public User()
        {
            nickName = "";
            UID = "";
            buyerCredit = new Credit();
            sellerCredit = new Credit();
            Location = new Location();
            Avatar = "";
            Email = "";
            Created = "";
        }
    }

    public class Credit
    {
        public string good_num { get; set; }
        public string level { get; set; }
        public string score { get; set; }
        public string total_num { get; set; }
        public string levelUri
        {
            get
            {
                if (level == "")
                    return "";
                int lv = Convert.ToInt32(level);
                switch(lv)
                {
                    case 1:
                        return "icons/red1.png";
                    case 2:
                        return "icons/red2.png";
                    case 3:
                        return "icons/red3.png";
                    case 4:
                        return "icons/red4.png";
                    case 5:
                        return "icons/red5.png";
                    case 6:
                        return "icons/zuan1.png";
                    case 7:
                        return "icons/zuan2.png";
                    case 8:
                        return "icons/zuan3.png";
                    case 9:
                        return "icons/zuan4.png";
                    case 10:
                        return "icons/zuan5.png";
                    case 11:
                        return "icons/king1.png";
                    case 12:
                        return "icons/king2.png";
                    case 13:
                        return "icons/king3.png";
                    case 14:
                        return "icons/king4.png";
                    case 15:
                        return "icons/king5.png";
                    case 16:
                        return "icons/gold1.png";
                    case 17:
                        return "icons/gold2.png";
                    case 18:
                        return "icons/gold3.png";
                    case 19:
                        return "icons/gold4.png";
                    case 20:
                        return "icons/gold5.png";
                    default:
                        return "";
                }
            }
            set
            {
                levelUri = value;
            }
        }
        public float good_rate
        {
            get 
            {
                if (total_num == "" || good_num == "")
                    return 0;
                int total = Convert.ToInt32(this.total_num);
                int good = Convert.ToInt32(this.good_num);
                if (total == 0)
                {
                    return 0;
                }
                else 
                {
                    float rate = (float)good*100 / (float)total;
                    return rate;
                }
            }
            set 
            {
                good_rate = value;
            }
        }
        public Credit()
        {
            //好评总条数
            good_num = "";
            //信用等级
            level = "";
            //信用总分
            score = "";
            //评价总条数
            total_num = "";
        }
    }

    public class Location
    {
        public string city { get; set; }
        public string state { get; set; }
        public string zip { get; set; }

        public Location()
        {
            city = "";
            state = "";
            zip = "";
        }
    }
}
